//
//  Created by  fred on 2017/1/12.
//  Copyright © 2016年 Alibaba. All rights reserved.
//

package top.zywork.common;
import com.alibaba.cloudapi.sdk.client.ApacheHttpClient;
import com.alibaba.cloudapi.sdk.enums.Scheme;
import com.alibaba.cloudapi.sdk.enums.HttpMethod;
import com.alibaba.cloudapi.sdk.model.ApiRequest;
import com.alibaba.cloudapi.sdk.model.ApiResponse;
import com.alibaba.cloudapi.sdk.model.ApiCallback;
import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
import com.alibaba.cloudapi.sdk.enums.ParamPosition;
import com.alibaba.cloudapi.sdk.enums.WebSocketApiType;
import com.alibaba.fastjson.JSONObject;


public class HttpApiClient extends ApacheHttpClient{
    public final static String HOST = "bankcard234.shumaidata.com";
    static HttpApiClient instance = new HttpApiClient();
    public static HttpApiClient getInstance(){return instance;}

    public void init(HttpClientBuilderParams httpClientBuilderParams){
        httpClientBuilderParams.setScheme(Scheme.HTTP);
        httpClientBuilderParams.setHost(HOST);
        super.init(httpClientBuilderParams);
    }




    public void BankCardVerification(String name , String idcard , String bankcard , String mobile , ApiCallback callback) {
        String path = "/bankcard234";
        ApiRequest request = new ApiRequest(HttpMethod.GET , path);
        request.addParam("name" , name , ParamPosition.QUERY , true);
        request.addParam("idcard" , idcard , ParamPosition.QUERY , false);
        request.addParam("bankcard" , bankcard , ParamPosition.QUERY , true);
        request.addParam("mobile" , mobile , ParamPosition.QUERY , false);



        sendAsyncRequest(request , callback);
    }

    public ApiResponse SyncMode(String name , String idcard , String bankcard , String mobile) {
        String path = "/bankcard234";
        ApiRequest request = new ApiRequest(HttpMethod.GET , path);
        request.addParam("name" , name , ParamPosition.QUERY , true);
        request.addParam("idcard" , idcard , ParamPosition.QUERY , false);
        request.addParam("bankcard" , bankcard , ParamPosition.QUERY , true);
        request.addParam("mobile" , mobile , ParamPosition.QUERY , false);



        return sendSyncRequest(request);
    }

}